#!/usr/local/bin/python3
# *_* coding: UTF-8 *_*
# @IDE: PyCharm
# @Version: Python3.97
# @Author: Kendrick.Kc
# @Email: 509556985@qq.com
# @File: public_ip.py
# @Inst: 获取本机IP
# @Time: 2023/6/23 13:43
# -----


import socket


def get_localhost_ip_address():
    try:
        # 获取本机主机名
        hostname = socket.gethostname()
        # 获取本机IP
        ip_address = socket.gethostbyname(hostname)
        return ip_address
    except:
        return None
